home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / hard / hack / i2clib38.lha / i2c_library.h < prev    next >
C/C++ Source or Header  |  1994-04-16  |  2KB  |  60 lines

  1. /*
  2. **     $Author: Bipsen $
  3. **     $Filename: i2c_library.h $
  4. **     $Release: 1.00 $
  5. **     $Revision: 37.2 $
  6. **     $Date: 1993/12/20 12:54:48 $
  7. **
  8. **     Headerfile to include in programs using i2c.library
  9. ** 
  10. */
  11.  
  12. #include <exec/libraries.h>
  13. #include <exec/types.h>
  14.  
  15. extern     struct Library *I2C_Base;
  16.  
  17. /*--- functions in v37.0 or higher ---*/
  18. #pragma libcall I2C_Base AllocI2C 1E 9002
  19. #pragma libcall I2C_Base FreeI2C 24 0
  20. #pragma libcall I2C_Base SetDelay 2A 001
  21. #pragma libcall I2C_Base InitI2C 30 0
  22. #pragma libcall I2C_Base SendI2C 36 91003
  23. #pragma libcall I2C_Base ReceiveI2C 3C 91003
  24. /*--- functions in v38.0 or higher ---*/
  25. #pragma libcall I2C_Base GetI2COpponent 42 0
  26.  
  27. /* Proto-types for functions */
  28.  
  29. BYTE AllocI2C(UBYTE Delay_Type,char *Name);
  30. void FreeI2C(void);
  31. void SetDelay(ULONG ticks);
  32. void InitI2C(void);
  33. UBYTE SendI2C(UBYTE addr, int number, UBYTE i2cdata[]);
  34. UBYTE ReceiveI2C(UBYTE addr, int number, UBYTE i2cdata[]);
  35. STRPTR GetI2COpponent(void);
  36.  
  37. /* Definitions for return-codes etc. */
  38.  
  39. /* Type of delay to pass as 1st parameter in AllocI2C */
  40. #define DELAY_TIMER 1    /* Use timer.device for SCL-delay  */
  41. #define DELAY_LOOP  2    /* Use for/next-loop for SCL-delay */
  42.  
  43. /* When using timer.device for delay, please notice, that the parameter */
  44. /* for SetDelay() will be in UNIT_MICROHZ. A value of 10 will probably  */
  45. /* give a clock-rate below 100 KHz as specified by the I2C-bus standard */
  46.  
  47.  
  48. /* Error-codes returned by AllocI2C */
  49. enum {I2C_OK=0, I2C_PORT_BUSY, I2C_BITS_BUSY, I2C_NO_MISC_RESOURCE,
  50.       I2C_ERROR_PORT, I2C_ACTIVE, I2C_NO_TIMER };
  51.  
  52. /* I2C_OK                Operation was OK                    */
  53. /* I2C_PORT_BUSY         Could not allocate parallel-port    */
  54. /* I2C_BITS_BUSY         Could not allocate the needed bits  */
  55. /* I2C_NO_MISC_RESOURCE  Could not get misc.resource         */
  56. /* I2C_ERROR_PORT        Could not open messageport          */
  57. /* I2C_ACTIVE            I2C-bus already active              */
  58. /* I2C_NO_TIMER          Cannot get timer                    */
  59.  
  60.